package com.wisewin.circle.api.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.servlet.ServletContextListener;
//import javax.servlet.annotation.WebListener;

//监听容器启动状态
//项目初始化以后，初始化ticket
//@WebListener
@Component
public class TicketManagerListener implements ServletContextListener {

    final static Logger log = LoggerFactory.getLogger(TicketManagerListener.class);
//
//    @Value("${spring.profiles.active}")
//    private String active;
//
//    @Override
//    public void contextInitialized(ServletContextEvent sce){
//        //判断环境
//        if ("prod".equals(active)){
//            log.info("-------------TicketManagerListener contextInitialized111111111111111111-------------");
//            TicketManager.init(WXConfig.PUBLIC_APPID,15,60*119);
//
//            log.info("-------------TicketManagerListener contextInitialized22222222222222222-------------");
//            TicketManager.init(WXConfig.PUBLIC_APPID2,15,60*119);
//        }else{
//            log.info("-------------非生产环境不进行定时刷新微信ticket-------------"+active);
//        }
//    }
//
//    @Override
//    public  void contextDestroyed(ServletContextEvent sce) {
//        if ("prod".equals(active)){
//            log.info("-------------TicketManagerListener contextDestroyed-------------");
//            TicketManager.destroyed();
//        }else{
//            log.info("-------------非生产环境不进行定时刷新微信ticket-------------"+active);
//        }
//    }

}
